
// alert('本网站商品每种一律限购1件！');

// 购买功能
{
    // 改变颜色 与 选中隐藏复选框 与 勾勾位置移动
    function changeColorAndChk(cn, judgechk, checkCir) {
        if (judgechk) {
            // 移除选中变色
            cn.style.backgroundColor = "#ebeef3";
            judgechk = false;
            // 移除选中复选框
            cn.children[2].checked = false;
            console.log("移除" + cn.children[2].value);
            // 移除选中勾勾移动
            checkCir.style.cssText = "opacity:0;bottom:3px;right:3px;";
            checkCir.classList.remove("trans");
            checkCir.style.cssText = "bottom:82px;right:82px";
        } else {
            // 选中变色
            cn.style.backgroundColor = "#cbd9f1";
            judgechk = true;
            // 选中复选框
            cn.children[2].checked = true;
            console.log("添加" + cn.children[2].value);
            // 选中勾勾移动
            checkCir.classList.add("trans");
            checkCir.style.cssText = "opacity:1;bottom:3px;right:3px;";
        }
        // 购物车小点点计数显示
        var chks = document.querySelectorAll("[type=checkbox][name=chk]:checked");
        var point = document.getElementsByClassName("Point")[0].children[0];
        point.innerText = chks.length;
    }

    // 添加所有选中商品到购物车
    function addAllGoodsInCart() {
        var cartgoods = document.querySelectorAll("[type=checkbox][name=chk]:checked");
        var list = document.getElementsByClassName("cart-show")[0];
        var sum = 0;

        // 打印前清空
        while (list.children.length > 0) {
            var li = list.children[0];
            console.log("删除");
            list.removeChild(li);
        }

        // 打印小票
        for (var i = 0; i < cartgoods.length; ++i) {
            var li = document.createElement("li");
            if (i == 0) {
                li.style.cssText = "border-top:none;";
            }
            li.innerText = cartgoods[i].value;
            list.appendChild(li);
            // 计算总价
            var temp = 0;
            for (var j = cartgoods[i].value.length - 1; j > 0; --j) {
                var n = (cartgoods[i].value.length - 1) - j;
                var k = 1;
                while (n-- > 0) {
                    k *= 10;
                }
                if (cartgoods[i].value[j] != '$') {
                    temp += parseInt(cartgoods[i].value[j]) * k;
                } else {
                    break;
                }
            }
            sum += temp;
        }
        // 打印总价
        var priceli = document.createElement("li");
        priceli.innerText = "合计：" + sum + ".0 圆";
        list.appendChild(priceli);
    }

    // 打开购物车
    function opencart() {
        if (window.localStorage.getItem("login-flag") == null) {
            alert('尚未登录');
            window.open('login.html');
            return;
        }
        var cart = document.getElementsByClassName("cart-div")[0];
        var bodycolor = document.getElementsByClassName("body-b")[0];
        cart.style.top = "18%";
        bodycolor.style.zIndex = "1045";
        bodycolor.style.backgroundColor = "#52525262";
        addAllGoodsInCart();
    }
    // 关闭购物车
    function exitcart() {
        var cart = document.getElementsByClassName("cart-div")[0];
        var bodycolor = document.getElementsByClassName("body-b")[0];
        cart.style.top = "-640px";
        bodycolor.style.zIndex = "-100";
        bodycolor.style.backgroundColor = "#00000001";
    }
    // 物品独立购买事件
    {
        var judgechk1 = false;
        // var ck = document.getElementsByClassName("o-1")[0];
        function changeColorAndChk1() {
            var cn = document.getElementsByClassName("c-1")[0];
            var ck = cn.children[0];
            if (judgechk1) {
                changeColorAndChk(cn, judgechk1, ck);
                judgechk1 = false;
            } else {
                changeColorAndChk(cn, judgechk1, ck);
                judgechk1 = true;
            }
        }

        var judgechk2 = false;
        function changeColorAndChk2() {
            var cn = document.getElementsByClassName("c-2")[0];
            var ck = cn.children[0];
            if (judgechk2) {
                changeColorAndChk(cn, judgechk2, ck);
                judgechk2 = false;
            } else {
                changeColorAndChk(cn, judgechk2, ck);
                judgechk2 = true;
            }
        }

        var judgechk3 = false;
        function changeColorAndChk3() {
            var cn = document.getElementsByClassName("c-3")[0];
            var ck = cn.children[0];
            if (judgechk3) {
                changeColorAndChk(cn, judgechk3, ck);
                judgechk3 = false;
            } else {
                changeColorAndChk(cn, judgechk3, ck);
                judgechk3 = true;
            }
        }

        var judgechk4 = false;
        function changeColorAndChk4() {
            var cn = document.getElementsByClassName("c-4")[0];
            var ck = cn.children[0];
            if (judgechk4) {
                changeColorAndChk(cn, judgechk4, ck);
                judgechk4 = false;
            } else {
                changeColorAndChk(cn, judgechk4, ck);
                judgechk4 = true;
            }
        }

        var judgechk5 = false;
        function changeColorAndChk5() {
            var cn = document.getElementsByClassName("c-5")[0];
            var ck = cn.children[0];
            if (judgechk5) {
                changeColorAndChk(cn, judgechk5, ck);
                judgechk5 = false;
            } else {
                changeColorAndChk(cn, judgechk5, ck);
                judgechk5 = true;
            }
        }

        var judgechk6 = false;
        function changeColorAndChk6() {
            var cn = document.getElementsByClassName("c-6")[0];
            var ck = cn.children[0];
            if (judgechk6) {
                changeColorAndChk(cn, judgechk6, ck);
                judgechk6 = false;
            } else {
                changeColorAndChk(cn, judgechk6, ck);
                judgechk6 = true;
            }
        }

        var judgechk7 = false;
        function changeColorAndChk7() {
            var cn = document.getElementsByClassName("c-7")[0];
            var ck = cn.children[0];
            if (judgechk7) {
                changeColorAndChk(cn, judgechk7, ck);
                judgechk7 = false;
            } else {
                changeColorAndChk(cn, judgechk7, ck);
                judgechk7 = true;
            }
        }

        var judgechk8 = false;
        function changeColorAndChk8() {
            var cn = document.getElementsByClassName("c-8")[0];
            var ck = cn.children[0];
            if (judgechk8) {
                changeColorAndChk(cn, judgechk8, ck);
                judgechk8 = false;
            } else {
                changeColorAndChk(cn, judgechk8, ck);
                judgechk8 = true;
            }
        }

        var judgechk9 = false;
        function changeColorAndChk9() {
            var cn = document.getElementsByClassName("c-9")[0];
            var ck = cn.children[0];
            if (judgechk9) {
                changeColorAndChk(cn, judgechk9, ck);
                judgechk9 = false;
            } else {
                changeColorAndChk(cn, judgechk9, ck);
                judgechk9 = true;
            }
        }

        var judgechk10 = false;
        function changeColorAndChk10() {
            var cn = document.getElementsByClassName("c-10")[0];
            var ck = cn.children[0];
            if (judgechk10) {
                changeColorAndChk(cn, judgechk10, ck);
                judgechk10 = false;
            } else {
                changeColorAndChk(cn, judgechk10, ck);
                judgechk10 = true;
            }
        }

        var judgechk11 = false;
        function changeColorAndChk11() {
            var cn = document.getElementsByClassName("c-11")[0];
            var ck = cn.children[0];
            if (judgechk11) {
                changeColorAndChk(cn, judgechk11, ck);
                judgechk11 = false;
            } else {
                changeColorAndChk(cn, judgechk11, ck);
                judgechk11 = true;
            }
        }

        var judgechk12 = false;
        function changeColorAndChk12() {
            var cn = document.getElementsByClassName("c-12")[0];
            var ck = cn.children[0];
            if (judgechk12) {
                changeColorAndChk(cn, judgechk12, ck);
                judgechk12 = false;
            } else {
                changeColorAndChk(cn, judgechk12, ck);
                judgechk12 = true;
            }
        }

        var judgechk13 = false;
        function changeColorAndChk13() {
            var cn = document.getElementsByClassName("c-13")[0];
            var ck = cn.children[0];
            if (judgechk13) {
                changeColorAndChk(cn, judgechk13, ck);
                judgechk13 = false;
            } else {
                changeColorAndChk(cn, judgechk13, ck);
                judgechk13 = true;
            }
        }

        var judgechk14 = false;
        function changeColorAndChk14() {
            var cn = document.getElementsByClassName("c-14")[0];
            var ck = cn.children[0];
            if (judgechk14) {
                changeColorAndChk(cn, judgechk14, ck);
                judgechk14 = false;
            } else {
                changeColorAndChk(cn, judgechk14, ck);
                judgechk14 = true;
            }
        }

        var judgechk15 = false;
        function changeColorAndChk15() {
            var cn = document.getElementsByClassName("c-15")[0];
            var ck = cn.children[0];
            if (judgechk15) {
                changeColorAndChk(cn, judgechk15, ck);
                judgechk15 = false;
            } else {
                changeColorAndChk(cn, judgechk15, ck);
                judgechk15 = true;
            }
        }

        var judgechk16 = false;
        function changeColorAndChk16() {
            var cn = document.getElementsByClassName("c-16")[0];
            var ck = cn.children[0];
            if (judgechk16) {
                changeColorAndChk(cn, judgechk16, ck);
                judgechk16 = false;
            } else {
                changeColorAndChk(cn, judgechk16, ck);
                judgechk16 = true;
            }
        }

        var judgechk17 = false;
        function changeColorAndChk17() {
            var cn = document.getElementsByClassName("c-17")[0];
            var ck = cn.children[0];
            if (judgechk17) {
                changeColorAndChk(cn, judgechk17, ck);
                judgechk17 = false;
            } else {
                changeColorAndChk(cn, judgechk17, ck);
                judgechk17 = true;
            }
        }

        var judgechk18 = false;
        function changeColorAndChk18() {
            var cn = document.getElementsByClassName("c-18")[0];
            var ck = cn.children[0];
            if (judgechk18) {
                changeColorAndChk(cn, judgechk18, ck);
                judgechk18 = false;
            } else {
                changeColorAndChk(cn, judgechk18, ck);
                judgechk18 = true;
            }
        }

        var judgechk19 = false;
        function changeColorAndChk19() {
            var cn = document.getElementsByClassName("c-19")[0];
            var ck = cn.children[0];
            if (judgechk19) {
                changeColorAndChk(cn, judgechk19, ck);
                judgechk19 = false;
            } else {
                changeColorAndChk(cn, judgechk19, ck);
                judgechk19 = true;
            }
        }

        var judgechk20 = false;
        function changeColorAndChk20() {
            var cn = document.getElementsByClassName("c-20")[0];
            var ck = cn.children[0];
            if (judgechk20) {
                changeColorAndChk(cn, judgechk20, ck);
                judgechk20 = false;
            } else {
                changeColorAndChk(cn, judgechk20, ck);
                judgechk20 = true;
            }
        }

        var judgechk21 = false;
        function changeColorAndChk21() {
            var cn = document.getElementsByClassName("c-21")[0];
            var ck = cn.children[0];
            if (judgechk21) {
                changeColorAndChk(cn, judgechk21, ck);
                judgechk21 = false;
            } else {
                changeColorAndChk(cn, judgechk21, ck);
                judgechk21 = true;
            }
        }

        var judgechk22 = false;
        function changeColorAndChk22() {
            var cn = document.getElementsByClassName("c-22")[0];
            var ck = cn.children[0];
            if (judgechk22) {
                changeColorAndChk(cn, judgechk22, ck);
                judgechk22 = false;
            } else {
                changeColorAndChk(cn, judgechk22, ck);
                judgechk22 = true;
            }
        }

        var judgechk23 = false;
        function changeColorAndChk23() {
            var cn = document.getElementsByClassName("c-23")[0];
            var ck = cn.children[0];
            if (judgechk23) {
                changeColorAndChk(cn, judgechk23, ck);
                judgechk23 = false;
            } else {
                changeColorAndChk(cn, judgechk23, ck);
                judgechk23 = true;
            }
        }

        var judgechk24 = false;
        function changeColorAndChk24() {
            var cn = document.getElementsByClassName("c-24")[0];
            var ck = cn.children[0];
            if (judgechk24) {
                changeColorAndChk(cn, judgechk24, ck);
                judgechk24 = false;
            } else {
                changeColorAndChk(cn, judgechk24, ck);
                judgechk24 = true;
            }
        }

        var judgechk25 = false;
        function changeColorAndChk25() {
            var cn = document.getElementsByClassName("c-25")[0];
            var ck = cn.children[0];
            if (judgechk25) {
                changeColorAndChk(cn, judgechk25, ck);
                judgechk25 = false;
            } else {
                changeColorAndChk(cn, judgechk25, ck);
                judgechk25 = true;
            }
        }


        var judgechk26 = false;
        function changeColorAndChk26() {
            var cn = document.getElementsByClassName("c-26")[0];
            var ck = cn.children[0];
            if (judgechk26) {
                changeColorAndChk(cn, judgechk26, ck);
                judgechk26 = false;
            } else {
                changeColorAndChk(cn, judgechk26, ck);
                judgechk26 = true;
            }
        }

        var judgechk27 = false;
        function changeColorAndChk27() {
            var cn = document.getElementsByClassName("c-27")[0];
            var ck = cn.children[0];
            if (judgechk27) {
                changeColorAndChk(cn, judgechk27, ck);
                judgechk27 = false;
            } else {
                changeColorAndChk(cn, judgechk27, ck);
                judgechk27 = true;
            }
        }

        var judgechk28 = false;
        function changeColorAndChk28() {
            var cn = document.getElementsByClassName("c-28")[0];
            var ck = cn.children[0];
            if (judgechk28) {
                changeColorAndChk(cn, judgechk28, ck);
                judgechk28 = false;
            } else {
                changeColorAndChk(cn, judgechk28, ck);
                judgechk28 = true;
            }
        }

        var judgechk29 = false;
        function changeColorAndChk29() {
            var cn = document.getElementsByClassName("c-29")[0];
            var ck = cn.children[0];
            if (judgechk29) {
                changeColorAndChk(cn, judgechk29, ck);
                judgechk29 = false;
            } else {
                changeColorAndChk(cn, judgechk29, ck);
                judgechk29 = true;
            }
        }

        var judgechk30 = false;
        function changeColorAndChk30() {
            var cn = document.getElementsByClassName("c-30")[0];
            var ck = cn.children[0];
            if (judgechk30) {
                changeColorAndChk(cn, judgechk30, ck);
                judgechk30 = false;
            } else {
                changeColorAndChk(cn, judgechk30, ck);
                judgechk30 = true;
            }
        }

        var judgechk31 = false;
        function changeColorAndChk31() {
            var cn = document.getElementsByClassName("c-31")[0];
            var ck = cn.children[0];
            if (judgechk31) {
                changeColorAndChk(cn, judgechk31, ck);
                judgechk31 = false;
            } else {
                changeColorAndChk(cn, judgechk31, ck);
                judgechk31 = true;
            }
        }

        var judgechk32 = false;
        function changeColorAndChk32() {
            var cn = document.getElementsByClassName("c-32")[0];
            var ck = cn.children[0];
            if (judgechk32) {
                changeColorAndChk(cn, judgechk32, ck);
                judgechk32 = false;
            } else {
                changeColorAndChk(cn, judgechk32, ck);
                judgechk32 = true;
            }
        }
    }
}

// 简易轮播图
{
    var imgs = document.getElementById("ul1").children;
    var index = -1;
    var ds;

    // 轮播启动函数
    restart();
    function restart() {
        ds = setInterval(function () {
            index++;
            if (index == imgs.length) {
                index = 0;
            }
            for (var i = 0; i < imgs.length; ++i) {
                imgs[i].style.cssText = "z-index:0;";
                botton[i].style.cssText = "background-color:#c5c5c5;";
            }
            imgs[index].style.cssText = "z-index:100;";
            botton[index].style.cssText = "background-color:#fff;";
        }, 2000);
    }

    // 轮播图左右切换按钮
    var leftbotton = document.getElementById("left-botton");
    var rightbotton = document.getElementById("right-botton");
    {
        leftbotton.onclick = function () {
            // alert(1);
            clearInterval(ds);
            index--;
            if (index < 0) {
                index = imgs.length - 1;
            }
            for (var i = 0; i < imgs.length; ++i) {
                imgs[i].style.cssText = "z-index:0;";
                botton[i].style.cssText = "background-color:#c5c5c5;";
            }
            imgs[index].style.cssText = "z-index:100;";
            botton[index].style.cssText = "background-color:#fff;";
            restart();
        }

        rightbotton.onclick = function () {
            // alert(1);
            clearInterval(ds);
            index++;
            if (index > imgs.length - 1) {
                index = 0;
            }
            for (var i = 0; i < imgs.length; ++i) {
                imgs[i].style.cssText = "z-index:0;";
                botton[i].style.cssText = "background-color:#c5c5c5;";
            }
            imgs[index].style.cssText = "z-index:100;";
            botton[index].style.cssText = "background-color:#fff;";
            restart();
        }
    }

    // 轮播图小圆点
    var botton = document.getElementById("ul2").children;
    {

        botton[0].addEventListener("mouseover", function () {
            clearInterval(ds);
            index = 0;
            for (var i = 0; i < imgs.length; ++i) {
                imgs[i].style.cssText = "z-index:0;";
                botton[i].style.cssText = "background-color:#c5c5c5;";
            }
            imgs[index].style.cssText = "z-index:100;";
            botton[0].style.cssText = "background-color: #fff;";
        });
        botton[0].addEventListener("mouseout", function () {
            restart();
        });

        botton[1].addEventListener("mouseover", function () {
            clearInterval(ds);
            index = 1;
            for (var i = 0; i < imgs.length; ++i) {
                imgs[i].style.cssText = "z-index:0;";
                botton[i].style.cssText = "background-color:#c5c5c5;";
            }
            imgs[index].style.cssText = "z-index:100;";
            botton[1].style.cssText = "background-color: #fff;";
        });
        botton[1].addEventListener("mouseout", function () {
            restart();
        });

        botton[2].addEventListener("mouseover", function () {
            clearInterval(ds);
            index = 2;
            for (var i = 0; i < imgs.length; ++i) {
                imgs[i].style.cssText = "z-index:0;";
                botton[i].style.cssText = "background-color:#c5c5c5;";
            }
            imgs[index].style.cssText = "z-index:100;";
            botton[2].style.cssText = "background-color: #fff;";
        });
        botton[2].addEventListener("mouseout", function () {
            restart();
        });

        botton[3].addEventListener("mouseover", function () {
            clearInterval(ds);
            index = 3;
            for (var i = 0; i < imgs.length; ++i) {
                imgs[i].style.cssText = "z-index:0;";
                botton[i].style.cssText = "background-color:#c5c5c5;";
            }
            imgs[index].style.cssText = "z-index:100;";
            botton[3].style.cssText = "background-color: #fff;";
        });
        botton[3].addEventListener("mouseout", function () {
            restart();
        });

        botton[4].addEventListener("mouseover", function () {
            clearInterval(ds);
            index = 4;
            for (var i = 0; i < imgs.length; ++i) {
                imgs[i].style.cssText = "z-index:0;";
                botton[i].style.cssText = "background-color:#c5c5c5;";
            }
            imgs[index].style.cssText = "z-index:100;";
            botton[4].style.cssText = "background-color: #fff;";
        });
        botton[4].addEventListener("mouseout", function () {
            restart();
        });

        botton[5].addEventListener("mouseover", function () {
            clearInterval(ds);
            index = 5;
            for (var i = 0; i < imgs.length; ++i) {
                imgs[i].style.cssText = "z-index:0;";
                botton[i].style.cssText = "background-color:#c5c5c5;";
            }
            imgs[index].style.cssText = "z-index:100;";
            botton[5].style.cssText = "background-color: #fff;";
        });
        botton[5].addEventListener("mouseout", function () {
            restart();
        });
    }

    // MouseOver轮播停止
    {
        var boxstop = document.getElementsByClassName("box-stop");
        console.log(boxstop);
        boxstop[0].addEventListener("mouseover", function () {
            clearInterval(ds);
        });
        boxstop[0].addEventListener("mouseout", function () {
            restart();
        });
    }
}

// 顶部导航红线
{
    // var navtd = document.getElementsByClassName("tr1").children;
    // var linenav = document.getElementsByClassName("head-nav").children;
    var navtd1 = document.getElementsByClassName("td-1");
    var linenav1 = document.getElementsByClassName("line-nav-1");
    navtd1[0].addEventListener("mouseover", function () {
        linenav1[0].style.cssText = "border: 1px solid rgb(200, 0, 0); background-color: rgb(200, 3, 3);";
    });
    navtd1[0].addEventListener("mouseout", function () {
        linenav1[0].style.cssText = "border: 0px solid rgb(200, 0, 0);";
    });

    var navtd2 = document.getElementsByClassName("td-2");
    var linenav2 = document.getElementsByClassName("line-nav-2");
    navtd2[0].addEventListener("mouseover", function () {
        linenav2[0].style.cssText = "border: 1px solid rgb(200, 0, 0); background-color: rgb(200, 3, 3);";
    });
    navtd2[0].addEventListener("mouseout", function () {
        linenav2[0].style.cssText = "border: 0px solid rgb(200, 0, 0);";
    });

    var navtd3 = document.getElementsByClassName("td-3");
    var linenav3 = document.getElementsByClassName("line-nav-3");
    navtd3[0].addEventListener("mouseover", function () {
        linenav3[0].style.cssText = "border: 1px solid rgb(200, 0, 0); background-color: rgb(200, 3, 3);";
    });
    navtd3[0].addEventListener("mouseout", function () {
        linenav3[0].style.cssText = "border: 0px solid rgb(200, 0, 0);";
    });

    var navtd4 = document.getElementsByClassName("td-4");
    var linenav4 = document.getElementsByClassName("line-nav-4");
    navtd4[0].addEventListener("mouseover", function () {
        linenav4[0].style.cssText = "border: 1px solid rgb(200, 0, 0); background-color: rgb(200, 3, 3);";
    });
    navtd4[0].addEventListener("mouseout", function () {
        linenav4[0].style.cssText = "border: 0px solid rgb(200, 0, 0);";
    });

    var navtd5 = document.getElementsByClassName("td-5");
    var linenav5 = document.getElementsByClassName("line-nav-5");
    navtd5[0].addEventListener("mouseover", function () {
        linenav5[0].style.cssText = "border: 1px solid rgb(200, 0, 0); background-color: rgb(200, 3, 3);";
    });
    navtd5[0].addEventListener("mouseout", function () {
        linenav5[0].style.cssText = "border: 0px solid rgb(200, 0, 0);";
    });

    var navtd6 = document.getElementsByClassName("td-6");
    var linenav6 = document.getElementsByClassName("line-nav-6");
    navtd6[0].addEventListener("mouseover", function () {
        linenav6[0].style.cssText = "border: 1px solid rgb(200, 0, 0); background-color: rgb(200, 3, 3);";
    });
    navtd6[0].addEventListener("mouseout", function () {
        linenav6[0].style.cssText = "border: 0px solid rgb(200, 0, 0);";
    });

    var navtd7 = document.getElementsByClassName("td-7");
    var linenav7 = document.getElementsByClassName("line-nav-7");
    navtd7[0].addEventListener("mouseover", function () {
        linenav7[0].style.cssText = "border: 1px solid rgb(200, 0, 0); background-color: rgb(200, 3, 3);";
    });
    navtd7[0].addEventListener("mouseout", function () {
        linenav7[0].style.cssText = "border: 0px solid rgb(200, 0, 0);";
    });

}


// 登录/注销 切换

if (window.localStorage.getItem("login-flag") == "true") {
    var lol = document.getElementsByClassName("loginOrLogout")[0];
    lol.innerText = "注销";
    lol.onclick = function () {
        window.localStorage.removeItem("login-flag");
        alert('已注销');
        location.reload();
    };
}
if (window.localStorage.getItem("login-flag") == null) {
    var lol = document.getElementsByClassName("loginOrLogout")[0];
    lol.innerText = "登录";
    lol.onclick = function () {
        window.open('login.html');
    };
}

function judgeLogin() {
    if (alert(window.localStorage.getItem("login-flag")) == false) {
        alert("尚未登录");
        location.reload();
    }
}

// 注册
function reg() {
    // alert(1);
    var account = document.getElementsByClassName("account")[0].value;
    var password1 = document.getElementsByClassName("password-1")[0].value;
    var password2 = document.getElementsByClassName("password-2")[0].value;
    if (account == '' || password1 == '' || password2 == '') {
        alert("请完整输入注册信息！");
        return;
    }
    if (window.localStorage.getItem(account) != null) {
        alert("该用户已经被注册！");
        return;
    }
    if (password1 != password2) {
        alert('两次密码不正确！');
        return;
    }
    // 添加数据
    window.localStorage.setItem(account, password1);
    alert("注册成功！");
    window.open('login.html');
    // 获取数据
    // alert(window.localStorage.getItem(account));
    // 清除某个数据
    // window.localStorage.removeItem("gender")
    // 清空所有数据
    // window.localStorage.clear()
}

// 登录
function login() {
    var account = document.getElementsByClassName("account-login")[0].value;
    var password = document.getElementsByClassName("password")[0].value;
    console.log(account);
    console.log(password);
    if (account != '手机号 / 邮件地址 / 账号名' && password == '密码') {
        alert("请输入密码！");
        return;
    }
    if (account == '手机号 / 邮件地址 / 账号名' && password != '密码') {
        alert("请输入登录账号！");
        return;
    }
    if (window.localStorage.getItem(account) == null) {
        alert("该用户不存在！");
        return;
    }
    if (window.localStorage.getItem(account) == password) {
        alert("登录成功！");
        window.localStorage.setItem("login-flag", true);
        window.open('main.html');
        afterLoginText();
    } else {
        alert("密码错误！");
    }
}
